package com.wimcorp.magic.cards;

import java.util.Set;

import javax.persistence.Entity;

import com.wimcorp.magic.abilities.Ability;
import com.wimcorp.magic.behaviour.Behaviour;
import com.wimcorp.magic.behaviour.Haste;
import com.wimcorp.magic.behaviour.SummoningSickness;
import com.wimcorp.magic.behaviour.Tapped;
import com.wimcorp.magic.color.Color;
import com.wimcorp.magic.cost.Cost;
import com.wimcorp.magic.exception.CastException;
import com.wimcorp.magic.exception.ManaException;

@Entity
public class BasicLand extends PlayingCard implements Permanent,Land {

	private String type = "Basic Land";

	
	
	protected BasicLand(){
		
	}

	public BasicLand(long multiverseid, String name, Set<Color> colors, Set<Behaviour> behaviours,Set<Ability> abilities, Cost... costs) {
		super(multiverseid, name, colors, behaviours,abilities,costs);
	}

	private BasicLand(PlayingCard card) {
		super(card);
	}

	@Override
	protected PlayingCard copy(PlayingCard original) {
		return new BasicLand(original);
	}

	@Override
	public void cast() {
		super.cast();
		getPlayer().getPlayerManaPool().addMana(getColor());
	}
	
	

	public Color getColor() {
		if (getColors().size() != 1) {
			throw new RuntimeException("Basic lane should only add 1 mana to playerpool. ");
		}
		return getColors().iterator().next();
	}
	
	public Color conjureMana() throws ManaException{
		Color color = getColor();
		if(!hasBehaviour(Tapped.instance())){
			addBehaviour(Tapped.instance());
		}
		else{
			throw new ManaException("You can't use tapped land to conjure mana. ");
		}
		return color;
	}

	public String getType() {
		return type;
	}

	

	/*public String toString() {
		StringBuilder card = new StringBuilder(getName());
		card.append("\n");
		card.append(getType());
		return card.toString();
	}*/

}
